package wlmap;
import javax.swing.*;

import java.awt.*;

import java.awt.event.ItemEvent;

import java.awt.event.ItemListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.io.File;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import java.util.TreeMap;

import java.util.TreeSet;



public class VisitPoint

{

    private JFrame jFrame;

    private JComboBox jComboBox;

    private JLabel jLabel;

    private JButton okayButton;
 



    private File file = new File("D://point.obj");

    private ObjectInputStream objectInputStream;



    private TreeMap treeMap;

    private Set set;



    public VisitPoint()

    {

      

            jFrame = new JFrame();

       

        frameInit();

    }



    public void frameInit()

    {

        try

        {

            jFrame.setLayout(new BorderLayout());

            jFrame.setBounds(700, 200, 350, 250);



        } catch (Exception e)

        {

            e.printStackTrace();

        }



        jComboBox = new JComboBox();

        jComboBox.setPreferredSize(new Dimension(270,30));

       

         
        TreeMap<String, String> treeMap = new TreeMap<String, String>();
        treeMap.put("校门", "师生出入");
        treeMap.put("一号楼", "教师办公楼");
        treeMap.put("二号楼", "学生上课");
        treeMap.put("三号楼", "学生上课");
        treeMap.put("四号楼", "学生上课");
        treeMap.put("食堂", "师生进餐");
        treeMap.put("宿舍", "学生学习休息");	    
        treeMap.put("图书馆", "图书阅览室");
			
		
           

            set = treeMap.keySet();

      

        Iterator iterator = set.iterator();

        while (iterator.hasNext())

        {

            jComboBox.addItem((String) iterator.next());

        }



        jLabel = new JLabel();

        jLabel.setPreferredSize(new Dimension(270,20));

        jLabel.setFont(new Font("宋体", 1, 20));

        jLabel.setText((String) treeMap.get(jComboBox.getSelectedItem()));



        jComboBox.addItemListener(new ItemListener()

        {

            @Override

            public void itemStateChanged(ItemEvent e)

            {

                jLabel.setText((String) treeMap.get(jComboBox.getSelectedItem()));

            }

        });



        okayButton = new JButton("确定");

        okayButton.setFont(new Font("微软雅黑", 1, 20));

        okayButton.addMouseListener(new MouseAdapter()

        {



            @Override

            public void mouseClicked(MouseEvent e)

            {

                jFrame.setVisible(false);

            }

        });

        jFrame.add(jComboBox,BorderLayout.NORTH);

        jFrame.add(jLabel,BorderLayout.CENTER);

        jFrame.add(okayButton,BorderLayout.SOUTH);

        jFrame.setResizable(false);

        jFrame.setVisible(true);

    }



    public static void main(String[] args)

    {

        new VisitPoint();

    }

}